<template>
    <vol-box
      :lazy="true"
      v-model="model"
      title="选择销售单"
      :height="400"
      :width="1200"
      :padding="5"
      :onModelClose="onModelClose"
    >
      <div>
        <paymentReceiptUndone ref="paymentReceiptUndone"></paymentReceiptUndone>
      </div>
      <template #footer>
        <div>
          <el-button type="primary" size="small" @click="onSelect"
            >确认</el-button
          >
        </div>
      </template>
    </vol-box>
  </template>
  <script>
  import VolBox from "@/components/basic/VolBox.vue";
  import paymentReceiptUndone from "@/views/paymentReceiptUndoneinfo/payment_receipt_undone/q_payment_receipt_undone.vue";
  //这里使用的vue2语法，也可以写成vue3语法
  export default {
    components: {
      "vol-box": VolBox,
      paymentReceiptUndone,
    },
    data() {
      return {
        model: false,
      };
    },
    methods: {
      async onModelClose() {
        this.$refs.paymentReceiptUndone.searchFormFields.AuditStatus = "1";
        await this.$refs.paymentReceiptUndone.$refs.grid.search();
      },
      open() {
        this.model = true;
      },
  
      onSelect() {
        let rowObj = this.$refs.paymentReceiptUndone.$refs.grid.getSelectRows();
        if (!rowObj.length) {
          this.$message.warning("请选择一条数据");
          return (this.model = true);
        }
        let AuditStatusSome = rowObj.some((item) => item.AuditStatus != 1);
        if (AuditStatusSome) {
          this.$message.error("请勿选择审核未通过单据");
          return;
        }
        this.$emit("parentCall", ($parent) => {
          $parent.editFormFields.Voucher_sub_paymentReceiptUndone = rowObj[0].Voucher_sub;
        });
        this.onModelClose();
        return (this.model = false);
      },
    },
  };
  </script>